
<div>
  <h1><%= @wiki.new_record? ? "新建百科" : "修改百科 ##{params[:id]}" %></h1>
</div>

<div class="form-body">
  <%= form_for @wiki,
    url: (@wiki.new_record? ? admin_wiki_index_path : admin_wiki_path(@wiki)),
    method: (@wiki.new_record? ? 'post' : 'put'),
    html: { class: 'form-horizontal' } do |f| %>

    <% unless @wiki.errors.blank? %>
      <div class="alert alert-danger">
        <ul class="list-unstyled">
          <% @wiki.errors.messages.values.flatten.each do |error| %>
            <li><i class="fa fa-exclamation-circle"></i> <%= error %></li>
          <% end -%>
        </ul>
      </div>
    <% end -%>

    <div class="form-group">
      <label for="brand" class="col-sm-2 control-label">分类*：</label>
      <div class="col-sm-5">
        <select name="wiki[wiki_category_id]">
          <% WikiCategory.all.each do |cate| %>
            <option value="<%= cate.id %>" <%= 'selected' if @wiki.wiki_category_id == cate.id %>><%= cate.title %></option>
          <% end %>
        </select>
      </div>
    </div>

    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">标题*:</label>
      <div class="col-sm-5">
        <%= f.text_field :title, class: "form-control", id: 'title' %>
      </div>
    </div>
    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">来源*:</label>
      <div class="col-sm-5">
        <%= f.text_field :source, class: "form-control", id: 'source', value: @wiki.source || "阳毅门窗" %>
      </div>
    </div>
    <div class="form-group">
      <label for="summary" class="col-sm-2 control-label">引言*:</label>
      <div class="col-sm-5">
        <%= f.text_area :summary, class: "form-control", id: 'summary', style: "height: 100px;" %>
      </div>
    </div>
    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">关键词（一行一个）*:</label>
      <div class="col-sm-5">
        <%= f.text_area :fake_tag_list, class: "form-control", style: "height: 100px", value: @wiki.tag_list.join("\r\n") %>
      </div>
    </div>
    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">正文*:</label>
      <div class="col-sm-5">
        <%= f.text_area :content, class: "form-control", id: 'editor-container' %>
      </div>
    </div>

    <div class="form-group">
      <div class="col-sm-offset-2 col-sm-8">
        <%= f.submit (@wiki.new_record? ? "新建百科" : "编辑百科"), class: "btn btn-primary" %>
      </div>
    </div>

  <% end -%>
</div>

